rack one's wits

(为某事)绞尽脑汁,苦思冥想;苦思冥想,绞尽脑汁